﻿using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;

namespace SingleBlog.Web
{
    using Models;
    using SingleBlog.Core.Data;
    using System.Collections.Generic;

    public static class PartialExtensions
    {
        const string TEMPLATE = "Templates";
        /// <summary>
        /// 呈现 _Article-Recommand-List 分布视图
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static IHtmlContent Partial_ArticleRecommandList(this IHtmlHelper htmlHelper, RecommandArticleViewModel model)
            => htmlHelper.Partial($"{TEMPLATE}/_Article-Recommand-List", model);
        /// <summary>
        /// 呈现 _Category-Article-Card 分布视图
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static IHtmlContent Partial_CategoryArticleCard(this IHtmlHelper htmlHelper, CategoryArticleViewModel model)
            => htmlHelper.Partial($"{TEMPLATE}/_Category-Article-Card", model);

        /// <summary>
        /// 呈现 _Category-List 分布视图
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <returns></returns>
        public static IHtmlContent Partial_CategoryList(this IHtmlHelper htmlHelper)
            => htmlHelper.Partial($"{TEMPLATE}/_Category-List");

        /// <summary>
        /// 呈现 _Article-List 分布视图
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="items">文章集合</param>
        /// <returns></returns>
        public static IHtmlContent Partial_ArticleList(this IHtmlHelper htmlHelper,IEnumerable<Article> items)
            => htmlHelper.Partial($"{TEMPLATE}/_Article-List",items);

        /// <summary>
        /// 呈现 _Comment-List 分布视图
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="items">The items.</param>
        /// <returns></returns>
        public static IHtmlContent Partial_CommentList(this IHtmlHelper htmlHelper, IEnumerable<Comment> items)
            => htmlHelper.Partial($"{TEMPLATE}/_Comment-List", items);

        /// <summary>
        /// 呈现回复表单视图
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <returns></returns>
        public static IHtmlContent Partial_CommentForm(this IHtmlHelper htmlHelper,int articleId)
            => htmlHelper.Partial($"{TEMPLATE}/_Comment-Form", new Comment { ArticleId = articleId });

        /// <summary>
        /// Partials the comment anonymous form.
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <returns></returns>
        public static IHtmlContent Partial_CommentAnonymousForm(this IHtmlHelper htmlHelper)
            => htmlHelper.Partial($"{TEMPLATE}/_Comment-Anonymous-Form",new AnonymousUserModel());
    }
}
